public class Student {

    private int age;
    private String name;
    private int studentId;
    private String className;

    private Student(Builder builder) {
        this.age = builder.age;
        this.name = builder.name;
        this.studentId = builder.studentId;
        this.className = builder.className;
    };

    public static class Builder {
        private int age;
        private String name;
        private int studentId;
        private String className;

        public Builder(String name) {
            this.name = name;
        }

        public Builder setAge(int age) {
            this.age = age;
            return this;
        }

        public Builder setStudentId(int studentId) {
            this.studentId = studentId;
            return this;
        }

        public Builder setClassName(String className) {
            this.className = className;
            return this;
        }

        public Student build() {
            return new Student(this);
        }
    }

    public String toString() {
        return "Student [age=" + age + ", name=" + name + ", studentId=" + studentId
                + ", className=" + className + "]";
    }

}
